from pydantic import BaseModel
from typing import Any, Union


class CommonResponse(BaseModel):
    data: Union[Any, None]
    code: int
    success: bool
    message: Union[str, None]


def success(data):
    return CommonResponse(data=data, code=0, success=True)


def successMessage(data, message: str):
    return CommonResponse(data=data, code=0, success=True, message=message)


def errorRes(message: str):
    return CommonResponse(code=-1, success=False, message=message)
